﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SQL_Provider;
using BusinessEntities;
using System.Data.SqlClient;
using System.Data;

namespace DataAccess
{
    public class PhieuDieuTri_Adapter
    {
        Provider db;
        public PhieuDieuTri_Adapter()
        {
            db = new Provider();
        }

        public int PhieuDieuTri_Them_NoiTru(PhieuDieuTri_Info info)
        {
            SqlParameter[] para = new SqlParameter[6];
            para[0] = new SqlParameter("@MaPhieu", info.MaPhieu);
            para[1] = new SqlParameter("@MaBA", info.MaBA);
            para[2] = new SqlParameter("@ThoiGianGhi", info.NgayGhiPhieu);
            para[3] = new SqlParameter("@YLenh", info.YLenh);
            para[4] = new SqlParameter("@MaBS", info.MaBS);
            para[5] = new SqlParameter("@TenBS", info.TenBS);
            return db.Execute_Modify("PhieuDieuTri_Them_NoiTru", para, CommandType.StoredProcedure);
        }

        public int PhieuDieuTri_CapNhat_NoiTru(PhieuDieuTri_Info info)
        {
            SqlParameter[] para = new SqlParameter[6];
            para[0] = new SqlParameter("@MaPhieu", info.MaPhieu);
            para[1] = new SqlParameter("@MaBA", info.MaBA);
            para[2] = new SqlParameter("@ThoiGianGhi", info.NgayGhiPhieu);
            para[3] = new SqlParameter("@YLenh", info.YLenh);
            para[4] = new SqlParameter("@MaBS", info.MaBS);
            para[5] = new SqlParameter("@TenBS", info.TenBS);
            return db.Execute_Modify("PhieuDieuTri_CapNhat_NoiTru", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_MaPhieu(int MaPhieu)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaPhieu", MaPhieu);
            return db.Execute_Table("PhieuDieuTri_MaPhieu", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_MaBA(int MaBA)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaBA", MaBA);
            return db.Execute_Table("PhieuDieuTri_MaBA", para, CommandType.StoredProcedure);
        }

        public int PhieuDieuTri_Xoa(int MaPhieu)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaPhieu", MaPhieu);
            return db.Execute_Modify("PhieuDieuTri_Xoa", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_MaBA_TrongNgay(int MaBA)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaBA", MaBA);
            return db.Execute_Table("PhieuDieuTri_MaBA_TrongNgay", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_All_MaBS(string MaBS)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaBS", MaBS);
            return db.Execute_Table("PhieuDieuTri_All_MaBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_All(string MaBS)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaBS", MaBS);
            return db.Execute_Table("PhieuDieuTri_All", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoMaPhieu_MaBS(string MaBS, int MaPhieu)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaBS", MaBS);
            para[1] = new SqlParameter("@MaPhieu", MaPhieu);
            return db.Execute_Table("PhieuDieuTri_TimTheoMaPhieu_MaBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoMaBA_TrongNgay(int MaBA)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaBA", MaBA);
            return db.Execute_Table("PhieuDieuTri_TimTheoMaBA_TrongNgay", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoMaBA_MaBS(string MaBS, int MaBA)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaBS", MaBS);
            para[1] = new SqlParameter("@MaBA", MaBA);
            return db.Execute_Table("PhieuDieuTri_TimTheoMaBA_MaBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoNgayGhi_MaBS(string MaBS, DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaBS", MaBS);
            para[1] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuDieuTri_TimTheoNgayGhi_MaBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoThangGhi_MaBS(string MaBS, DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaBS", MaBS);
            para[1] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuDieuTri_TimTheoThangGhi_MaBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoNamGhi_MaBS(string MaBS, DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MaBS", MaBS);
            para[1] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuDieuTri_TimTheoNamGhi_MaBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_BNXuatVien()
        {
            SqlParameter[] para = new SqlParameter[0];
            return db.Execute_Table("PhieuDieuTri_BNXuatVien", para, CommandType.StoredProcedure);
        }

        // Tìm Kiếm Quản lý
        public DataTable PhieuDieuTri_TimTheoMaBS(string MaBS)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@MaBS", MaBS);
            return db.Execute_Table("PhieuDieuTri_TimTheoMaBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoTenBS(string TenBS)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@TenBS", TenBS);
            return db.Execute_Table("PhieuDieuTri_TimTheoTenBS", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoNgayGhi(DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuDieuTri_TimTheoNgayGhi", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoThangGhi(DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuDieuTri_TimTheoThangGhi", para, CommandType.StoredProcedure);
        }

        public DataTable PhieuDieuTri_TimTheoNamGhi(DateTime ThoiGianGhi)
        {
            SqlParameter[] para = new SqlParameter[1];
            para[0] = new SqlParameter("@ThoiGianGhi", ThoiGianGhi);
            return db.Execute_Table("PhieuDieuTri_TimTheoNamGhi", para, CommandType.StoredProcedure);
        }
    }
}
